﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonEmpCertInfo.aspx.cs"
    Inherits="RN.ERP.Web.Person.PersonEmpCertInfo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><%=PageTitle %></title>
    <link href="../Styles/skins/blue/css/style.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/skins/blue/css/style_msg.css" rel="stylesheet" type="text/css" />
    <link rel="Stylesheet" type="text/css" href="../Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <script src="../Scripts/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" src="../Scripts/json-data.js"></script>
    <script type="text/javascript" src="../Scripts/iepngfix_tilebg.js"></script>
    <script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.min.js"></script>
    <script src="../Scripts/PsnEmpInfoSelect.js" type="text/javascript"></script>
    <style type="text/css">
        .IE6png
        {
            behavior: url("../Scripts/iepngfix.htc");
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <input type="hidden" id="hidCurrentCorpName" value="" />
    <input id="hdStatus" type="hidden" runat="server" value="0" />
    <table width="770" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
            <td width="16" class="title_lbg IE6png">
            </td>
            <td width="24" class="title_t IE6png">
            </td>
            <td width="713" class="title_libg IE6png">
                <asp:Literal ID="lblTitle" runat="server">人员资格</asp:Literal>
            </td>
            <td width="17" class="title_rbg IE6png">
            </td>
        </tr>
        <tr>
            <td class="border_lbg IE6png">
                &nbsp;
            </td>
            <td colspan="2">
                <div id="con">
                    <ul id="tags">
                        <li class="selectTag"><a href="javascript:void(0)">
                            <asp:Literal ID="lblTitleSub" runat="server">专业证书</asp:Literal></a> </li>
                    </ul>
                    <div id="tagContent">
                        <div class="tagContent selectTag" id="empTitleDetails" table="tb_emp_titledetails"
                            valtype="1">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="xx_tab">
                                <tr>
                                    <td width="67" align="right">
                                        证书类别
                                         <input id="hdManualID" type="hidden" runat="server" value="ZGZS" control="StampCode" />
                                        <input id="hdEmpGuid" type="hidden" runat="server" value="" control="EmpGuid" />
                                        <input id="hdEducationGUID" type="hidden" runat="server" value="" control="EducationGUID" />
                                         <input id="hdIsValid" runat="server" type="hidden"  value="0" control="IsValid" />
                                    </td>
                                    <td>
                                        <div class="s_input" id="certDiv">
                                            <span class="input_l">
                                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                    <input id="txtCertType" name="text" type="text" value="" maxlength="30" style="width: 205px;
                                                        height: 31px; line-height: 31px; border: 0; background: transparent;" controlvalid="checkEmpty(this,'')"
                                                        controltext="证书类别" disabled="disabled" />
                                                    <i><a href="javascript:void(0)" title="选择证书类别" class="imgZoom" id="certTypeA"></a></i></span>
                                            <span class="input_r">
                                                <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                        </div>
                                 
                                        <input id="hdnTypeFlags" type="hidden" value="-1" control="TypeFlags"/>
                                        <input id="hdnCertificateName" type="hidden" value="请选择" control="CertificateName"/>
                                        <input id="hdnCertificateLevel" type="hidden" value="-1" control="CertificateLevel"/>
                                        <input id="hdnCLCode" type="hidden" value="不分等级" control="CLCode"/>
                               <input id="hdnTypeId" type="hidden" value="-1"/>
                                      <select name="" id="selCertificateName" runat="server" style="display:none;">
                                                        <option value="-1" vls='-1'>请选择</option>
                                                    </select>
                                    </td>
                                     <td width="67" align="right">
                                       注册单位
                                    </td>
                                    <td  valign="top">
                                     <div class="s_input">
                                            <span class="input_l">
                                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                    <input name="text" type="text" value="" style="width: 275px; height: 31px; line-height: 31px;
                                                        border: 0; background: transparent; overflow: hidden" 
                                                        control="RegisterCorpName" id="txtCorpName"  maxlength="50" />
                                                </span><span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                        </div>
                                    </td>
                                   
                                </tr>
                                <tr>
                                    <td width="67" align="right">
                                        专业
                                    </td>
                                    <td>
                                      <div class="s_input">
                                            <span class="input_l">
                                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                 <select name="" id="selCSCode" runat="server" style="width: 205px; height: 20px;
                                                        line-height: 31px; margin-top: 5px; border: 0;" controltype="drop" control="CertificateSpecialty,CSCode"
                                                        controlvalid="SelEmpty(this,'-1')" controltext="专业">
                                                        <option value="-1" vls='-1'>请选择</option>
                                                    </select> 
                                                </span><span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                        </div>
                                    </td>
                                     <td width="67" align="right">
                                        证书编号
                                    </td>
                                    <td>
                                        <div class="s_input" id="codeDiv">
                                            <span class="input_l">
                                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> 
                                                <span class="input_mm">
                                                <select id="selPrefix" style="display: none; float:left; border:none; margin-top:5px; margin-right:5px;">
                                                    </select>
                                                    <input name="text" id="txtCertificateCode" type="text" value="" style="width:115px;
                                                        height: 31px; line-height: 31px; border: 0; background: transparent; float:left;"
                                                        maxlength="50" controlvalid="checkEmpty(this,'')" controltext="注册编号" />
                                                      </span>
                                            <span class="input_r">
                                                <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                        </div>
                                          <input id="hdnCertificateCode" type="hidden" value="" control="CertificateCode"/>
                                    </td>
                                  
                                </tr>
                                <tr>
                                  <td width="67" align="right">
                                       签发日期
                                    </td>
                                    <td>
                                        <div class="s_input">
                                            <span class="input_l">
                                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                    <input name="text" id="txtGetCertificateDate" runat="server" type="text" value=""
                                                        style="width: 275px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                        onclick="WdatePicker({skin:'blue',maxDate:'%y-%M-%d'})" control="GetCertificateDate"
                                                        maxlength="10" controlvalid="checkEmpty(this,'')" controltext="签发日期" /></span>
                                            <span class="input_r">
                                                <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                        </div>
                                    </td>
                                     <td width="67" align="right">
                                        有效期至
                                    </td>
                                    <td>
                                         <div class="s_input">
                                            <span class="input_l">
                                                <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                    <input name="text" type="text" value="" style="width: 275px; height: 31px; line-height: 31px;
                                                        border: 0; background: transparent; overflow: hidden" onclick="WdatePicker({skin:'blue',minDate:'%y-%M-{%d+1}'})"
                                                        control="ZsEndDate" id="txtZsEndDate" runat="server" maxlength="10" />
                                                </span><span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                        </div>
                                    </td>
                                  
                                </tr>
                                <tr>
                                 
                                    <td width="67" align="right" valign="top">
                                        上传证书
                                    </td>
                                    <td align="left" colspan="3">
                                    <div runat="server" id="certImgDiv">
                                    <a href="javascript:void(0);" id="certImgUpload"><img alt="上传" src="../images/btn.jpg" /></a>
                                       </div>
                                        <div> <img src='' id="certimg" alt="" style="display: none; width: 220px; height: 150px;" class="pointer"/>
                                            </div>
                                    </td>
                                 
                                </tr>
                            </table>
                            <table  height="80" border="0" align="center" cellpadding="0" cellspacing="0" runat="server" id="btnSaveDiv"
                                class="xx_tab">
                                <tr>
                                   
                                    <td width="144" height="80">
                                        <div class="icon01 IE6png">
                                            <a id="btnSave" parentdiv="empTitleDetails" href="javascript:void(0);">保存</a></div>
                                    </td>
                                    <td width="11" height="80">
                                        &nbsp;
                                    </td>
                                    <td width="144" height="80">
                                        <div class="icon02 IE6png">
                                            <a id="btnCancel" href="javascript:void(0);">关闭</a></div>
                                    </td>
                                   
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </td>
            <td class="border_rbg IE6png">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="border_lconer IE6png" headers="17">
                &nbsp;
            </td>
            <td colspan="2" class="border_bottomli IE6png" height="17">
                &nbsp;
            </td>
            <td class="border_rconer IE6png" headers="17">
                &nbsp;
            </td>
        </tr>
    </table>
    <div id="ImgDialog" style="margin: auto; width: 600px;">
        <telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadWindowManager ID="Manager1" runat="server" EnableShadow="true" Skin="WebBlue">
            <Windows>
                <telerik:RadWindow ID="RadW1" runat="server" Title="" Height="280px" Behaviors="Close"
                    Width="550px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"
                    Modal="true" Skin="WebBlue" VisibleStatusbar="False">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    var empGuid;
    var status;
    var educationGUID;
    var editStatus;
    var manualID;
    var selCurrentVal="";
    $(function () {
        manualID = $("#<%= hdManualID.ClientID%>").val();
        empGuid = $("#<%= hdEmpGuid.ClientID%>").val();
        status = $("#<%= hdStatus.ClientID%>").val();
        educationGUID = $("#<%= hdEducationGUID.ClientID%>").val();
        Certificate = "<%=selCertificateName.ClientID %>";
        CSCode = "<%=selCSCode.ClientID %>";
      
        editStatus = "<%=EditStatus %>";
        empCertType = manualID; //加载列表时区分资格证书和执业手册标识
        Initial();
        SetControlEdit(editStatus); //控件编辑状态设置
        CertCodeValid();
    });
    /*初始化页面*/
    function Initial() {
        $("#btnSave").click(function () {
            EmpTitleDetailsSave("btnSave");
        });
        $("#btnCancel").click(function () {
            returnToParent(1);
            CloseClildWorkExpWin();
        });
        //图片上传begin
        $("#certImgUpload").click(function () {
            if (empGuid == "") {
                OpenAlert("请先添加人员信息！");
                return false;
            }
            var title = "上传注册证书扫描件";
            $.ligerDialog.open({ url: "../UserControl/FileUploadList.aspx?title=" + escape(title) + "&filename=" + educationGUID + "&FuncCode=PersonZG", width: 650, height: 570, title: '', buttons: [{ text: '选择', onclick: function (item, dialog) { dialog.close(); } }] });
            return false;
        });
        //end
        if (status == "1") {
            GetQualities();
            ImgShow1();
        } 
        else {
            SelCertAll(manualID, 0, Certificate, "-1", ""); //证书类别，加载专业时使用
        }
    }
    /*专业*/
    function BindCertSpecialty(code) {
        var parentId = $("#"+Certificate + " option[value='" + $("#hdnTypeFlags").val() + "']").attr("vls");
        if (parentId == "-1") {
            $("#" + CSCode).empty();
            SetDefaultSelVal(CSCode);
            return false;
        }
        SelCertAll("specialty", parentId, CSCode, code, "");
    }
    /*取得编号格式*/
    function GetQualityCodeValid(typeFlag, level) {
        var current = $("#hdnCertificateCode").val();
        if (editStatus != "0") {
           //查看状态赋值
            $("#txtCertificateCode").attr("disabled", "disabled");
            $("#txtCertificateCode").val(current);
            return false;
        }
        $.getJSON("PersonEmpCertInfo.aspx", { "action": "GetCodeValid", "code": "EmpTitleDetails", "typeFlags": typeFlag, "certLevel": level, "rand": Math.random() }, function (data) {
            if (data != null) {
               //绑定前缀下拉列表
                SetCodeOptionVals(data.PreifxContent, data.LevelPreifx, data.PrefixType);
                //编号前缀和编号文本赋值
                CheckQualityCodeValid(data.RegExpress, data.PrefixType, current);    
            }
            return false;
        });
    }
    /*添加编号格式下拉列表内容*/
    function SetCodeOptionVals(data1, data2,type) {
        var data = [];
        //证书类别前缀
        if (data1 != null) {
            data = data1.split('|');
        }
        //证书等级前缀
        var item = "";
        if (data2 != null) {
            item = data2;
        }
        $("#selPrefix").empty();
        $("#selPrefix").hide();
        if (type != "0") {
        //有类别前缀加载下拉列表
            for (var i = 0, j = data.length; i < j; i++) {
                $("#selPrefix").append("<option value='" + data[i] + item + "'>" + data[i] + item + "</option>");
                if (data[i].indexOf("鲁") >= 0) {
                    selCurrentVal = data[i] + item;//设置下拉默认值
                }
            }
        }
        //列表为空加空白默认值
        if ($("#selPrefix option").length == 0) {
            $("#selPrefix").append("<option value='" + item + "'>" + item + "</option>");
        }
        //有前缀格式限制显示下拉
        if ($("#selPrefix option").length > 0 && $("#selPrefix").val() != "") {
            $("#selPrefix").show();
        }
    }
    /*分解证书编号赋值下拉列表和文本框*/
    function CheckQualityCodeValid(regval, type,current) {
        //根据规则分解编号
        if (current != "" && type != "0") {
            var r = new RegExp(regval);
            var s1 = current.replace(r, "$1");
            var s2 = current.replace(r, "$2");
            $("#selPrefix").val(s1);
            $("#txtCertificateCode").val(s2);
        } else {
            $("#selPrefix").val(selCurrentVal); 
            $("#txtCertificateCode").val(current);
        }
    }
   
    /*打开验证页面*/
    function CertCodeValid() {
        if (editStatus != "0") {
            $(".imgZoom").hide();
            return false;
        }
        $(".imgZoom").click(function () {
            $.ligerDialog.open({ url: "PersonEmpCertCodeValid.aspx?Code=EmpTitleDetails&manual=" + manualID, width: 400, height: 450, title: '', isResize: true, allowClose: false });
            return false;
        });
    }
    /*取得信息**/
    function GetQualities() {
        $.getJSON("PersonEmpCertInfo.aspx", { "action": "GetQualities", "empGuid": empGuid, "certGuid": educationGUID, "rand": Math.random() }, function (data) {
            if (data.length == 0 || data == null) {
                OpenAlert("未查询到有效数据！");
                return false;
            }
            if (data.result == 1) {
                OpenAlert(data.message);
                return false;
            }
            var items = data.data;

            if (items != null) {
                SetControlVal("empTitleDetails", items); //页面控件赋值
                //                level = items.CertificateLevel;
                specil = items.CertificateSpecialty;
                $("#txtCertType").val($("#hdnCertificateName").val() + " " + $("#hdnCLCode").val());
                SelCertAll(manualID, 0, Certificate, items.TypeFlags, "-1"); //下拉列表赋值
                GetQualityCodeValid(items.TypeFlags, items.CertificateLevel);
                if (items.IsValid == "100") {
                    $("#certDiv").attr("disabled", "disabled");
                    $("#" + CSCode).attr("disabled", "disabled");
                    $("#codeDiv").attr("disabled", "disabled");
                    $("#certTypeA").attr("disabled", "disabled");
                    $("#txtCorpName").attr("disabled", "disabled");
                }
                $("#hidCurrentCorpName").val(items.RegisterCorpName);//取得单位
            }
        });
    }
    /*保存信息*/
    function EmpTitleDetailsSave(btnId) {
        if (empGuid == "") {
            OpenAlert("请先添加人员信息！");
            return false;
        }
        //验证控件值
        var dataValid = CheckControlValid(btnId);
        if (!dataValid) {
            return false;
        }
        $("#hdnCertificateCode").val($.trim($("#selPrefix").val()+$("#txtCertificateCode").val()));
        $("#" + btnId).attr("disabled", "disabled");
        if (status == "0") {
            EmpTitleDetailsAdd(btnId, "QualitieAdd");
        } else {
            EmpTitleDetailsAdd(btnId, "QualitieEdit");
        }
    }
    /*添加修改信息*/
    function EmpTitleDetailsAdd(btnId, action) {
        var dataStr = GetData(btnId);//取得页面上的输入值
        $.getJSON("PersonEmpCertInfo.aspx", { "action": action, "empGuid": empGuid, "data": dataStr, "entityName": $("#hidCurrentCorpName").val(), "rand": Math.random() }, function (data) {
            $("#" + btnId).removeAttr("disabled");

            if (data.Result) {
                if (action == "QualitieAdd") {
                    returnToParent(0);
                    OpenAlertFn(data.Message, function () { window.location = window.location.href; });
                } else {
                    OpenAlertFn(data.Message, closeChildWin);
                }
                // returnToParent(0);
            } else {
                //未上传的图片提示
                if (data.Message == "img") {
                    OpenAlert(data.ReturnValue);
                    return false;
                }
                OpenAlert(data.Message);
            }
        });
    }
    /*取得资格证书类别等级*/
    function OnClientCloseCertType(args) {
        var arg = args;
        if (arg) {
            if (arg.Result == 0) {
                return;
            }
            $("#hdnTypeFlags").val(arg.typeFlags);
            $("#hdnCertificateName").val(arg.certName);
            $("#hdnCertificateLevel").val(arg.Level);
            $("#hdnCLCode").val(arg.CLCode);
            $("#txtCertType").val(arg.certName + " " + arg.CLCode);
            BindCertSpecialty("-1");
            GetQualityCodeValid(arg.typeFlags, arg.Level);
        }
    }
 
    /*关闭子窗口执行事件*/
    function OnClientCloseImg(args) {
        var arg = args;
        if (arg) {
            if (arg.Result == 1) {
                return;
            }
            ImgShow1();
        }
    }
    /*加载图片*/
    function ImgShow1() {
        var title = "查看注册证书扫描件";
        $("#certimg").attr("src", "../Handlers/GetFileHandler.ashx?fileName=" + educationGUID + ".jpg&sysCode=EF&funcCode=PersonZG&rand=" + Math.random());
        $("#certimg").click(function () {
            $.ligerDialog.open({ url: "../Enterprise/UploadFileShowList.aspx?title=" + escape(title) + "&fileName=" + educationGUID + "&fileType=.jpg&sysCode=EF&funcCode=PersonZG", width: 760, height: 650, title: '', isResize: true, buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }] });
            return false;
        });
        $("#certimg").show();
    }
    /*关闭窗口*/
    function closeChildWin() {
        returnToParent(0);
        CloseClildWorkExpWin();
    }
    function returnToParent(result) {
        var oArg = new Object();
       //资格证书
        if (manualID == "ZGZS") {
            oArg.childWinName = "Cert"; 
        }else if (manualID == "Cert-Expert") {
            oArg.childWinName = "Cert-Expert"; //专家
        } else {
            oArg.childWinName = "CertSC";//执业手册
        }
        oArg.Result = result;
        parent.window.OnClientClose(oArg);
       
    }
    function CloseClildWorkExpWin() {
        window.parent.$.ligerDialog.close(); ////关闭dialog
        parent.$(".l-dialog,.l-window-mask").hide(); ////去除父窗体遮罩层
        parent.window.focus(); //返回焦点
    }
    function OpenAlert(text) {
        $.ligerDialog.warn(text);
        return false;
    }
    function OpenAlertFn(text, CallBackFn) {
        $.ligerDialog.warn(text, '', CallBackFn);
        return false;
    }

    /*打开添加窗口*/
    function ShowUpForm(u, w, h, win) {
        win = win || this;
        $.ligerDialog.open({ url: u, width: w, height: h, title: '', buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }] });
        win.ChildDialogWin = this;
        return false;
    }
</script>
